package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;

public class ReflectDemo8 {
    public static void main(String[] args) throws Exception{
        Class cls=Class.forName("reflect.Person");
        Method method=cls.getMethod("say",String.class,int.class);
        String name = method.getName();
        System.out.println("方法名:"+name);
        Class retunType=method.getReturnType();
        System.out.println("返回类型:"+retunType);
        Class [] parametetTypes=method.getParameterTypes();
        System.out.println("参数类型:"+ Arrays.toString(parametetTypes));
        int parameterCount = method.getParameterCount();
        System.out.println("参数个数:"+parameterCount);
        int modifier = method.getModifiers();
        switch(modifier){
                case Modifier.PRIVATE:
                System.out.println("私有方法");break;
                case Modifier.PUBLIC:
                    System.out.println("共有方法");break;
                case Modifier.PROTECTED:
                    System.out.println("受保护的方法");break;
                default:
                    System.out.println("默认方法");
        }
    }
}
